from tkinter import *
from tkinter.ttk import *
from tkinter import messagebox
import tkinter as tk
from settingHelper import setting
from projectHelper import project
from menu import createMenu
import menu
from shortcut import bindAllShortcutKeys
from utils import updateTitle
import widgets, utils
import math


def showConfirmExit():
    if utils.modified:
        select = messagebox.askyesnocancel("退出程序", "是否保存当前项目")
        if select is None or (select and not menu.saveProject()):
            return
    root.quit()


root: Tk = Tk()
widgets.root = root
updateTitle()
root.iconbitmap("lemonade.ico")
root.state("zoomed")


bindAllShortcutKeys(root)
createMenu(root)
root.protocol("WM_DELETE_WINDOW", showConfirmExit)

widgets.canvasVideo = Canvas(root, width=800, height=400)
widgets.canvasFull = Canvas(root, width=800, height=400)
widgets.canvasVideo.grid(row=0, column=0, rowspan=4, columnspan=8)
widgets.canvasFull.grid(row=0, column=8, rowspan=4, columnspan=8)

widgets.canvasVideo.create_rectangle(0, 0, 800, 400, fill="black")
widgets.canvasFull.create_rectangle(0, 0, 800, 400, fill="blue")

widgets.infoPanel = Frame(root)
widgets.infoPanel.grid(row=0, column=16, rowspan=4, columnspan=4)

widgets.controlPanel = Notebook(
    root, width=root.winfo_width(), height=math.floor(root.winfo_height() * 0.6)
)
widgets.controlPanel.grid(row=4, column=0, rowspan=6, columnspan=20)

widgets.playPanel = Frame(widgets.controlPanel)
widgets.settingPanel = Frame(widgets.controlPanel)
widgets.displayPanel = Frame(widgets.controlPanel)

widgets.controlPanel.add(widgets.playPanel, text="播放")
widgets.controlPanel.add(widgets.settingPanel, text="编辑")
widgets.controlPanel.add(widgets.displayPanel, text="显示器映射")


# sv_ttk.set_theme('dark',root)

root.mainloop()
